package com.my.swas.photo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description:
 * @author: :MaYong
 */
@Configuration //标记配置类
@EnableSwagger2 //开启在线接口文档
public class Swagger2Config {

    @Value("${photo.swagger.enbale}")
    private Boolean swagger_enable;

    @Bean(value = "sysApi")
    @Order(value = 1)
    public Docket Api() {
        ParameterBuilder parameterBuilder = new ParameterBuilder();

        return new Docket(DocumentationType.SWAGGER_2)
                .enable(swagger_enable)
                .apiInfo(apiInfo())
                .groupName("电子照接口管理")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.my.swas.photo.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("电子照接口管理")
                .description("包括用户管理，角色管理，权限管理等")
                .termsOfServiceUrl("http://www.xx.com/")
                .version("1.0")
                .build();
    }


}
